<!DOCTYPE html>

<html>

  <head>
    <title>Robotic Manipulation: Drake</title>
    <meta name="Robotic Manipulation: Drake" content="text/html; charset=utf-8;" />
    <link rel="canonical" href="http://manipulation.csail.mit.edu/drake.html" />

    <script src="https://hypothes.is/embed.js" async></script>
    <script type="text/javascript" src="htmlbook/book.js"></script>

    <script src="htmlbook/mathjax-config.js" defer></script> 
    <script type="text/javascript" id="MathJax-script" defer
      src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
    </script>
    <script>window.MathJax || document.write('<script type="text/javascript" src="htmlbook/MathJax/es5/tex-chtml.js" defer><\/script>')</script>

    <link rel="stylesheet" href="htmlbook/highlight/styles/default.css">
    <script src="htmlbook/highlight/highlight.pack.js"></script> <!-- http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases -->
    <script>hljs.initHighlightingOnLoad();</script>

    <link rel="stylesheet" type="text/css" href="htmlbook/book.css" />
  </head>

<body onload="loadChapter('manipulation');">

<div data-type="titlepage">
  <header>
    <h1><a href="index.html" style="text-decoration:none;">Robotic Manipulation</a></h1>
    <p data-type="subtitle">Perception, Planning, and Control</p> 
    <p style="font-size: 18px;"><a href="http://people.csail.mit.edu/russt/">Russ Tedrake</a></p>
    <p style="font-size: 14px; text-align: right;"> 
      &copy; Russ Tedrake, 2020<br/>
      Last modified <span id="last_modified"></span>.</br>
      <script>
      var d = new Date(document.lastModified);
      document.getElementById("last_modified").innerHTML = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();</script>
      <a href="misc.html">How to cite these notes, use annotations, and give feedback.</a><br/>
    </p>
  </header>
</div>

<p><b>Note:</b> These are working notes used for <a
href="http://manipulation.csail.mit.edu/Fall2020/">a course being taught
at MIT</a>. They will be updated throughout the Fall 2020 semester.  <!-- <a 
href="https://www.youtube.com/channel/UChfUOAhz7ynELF-s_1LPpWg">Lecture  videos are available on YouTube</a>.--></p> 

<table style="width:100%;"><tr style="width:100%">
  <td style="width:33%;text-align:left;"><a class="previous_chapter" href=rl.html>Previous Chapter</a></td>
  <td style="width:33%;text-align:center;"><a href=index.html>Table of contents</a></td>
  <td style="width:33%;text-align:right;"><a class="next_chapter" href=station.html>Next Chapter</a></td>
</tr></table>


<!-- EVERYTHING ABOVE THIS LINE IS OVERWRITTEN BY THE INSTALL SCRIPT -->
<chapter class="appendix" style="counter-reset: chapter 0"><h1>Drake</h1>

  <p><drake></drake> is the main software toolbox that we use for this text,
  which in fact originated in a large part due to the MIT underactuated course.
  The <drake></drake> website is the main source for information and
  documentation.  The goal of this chapter is to provide any additional
  information that can help you get up and running with the examples and
  exercises provided in these notes.</p>

  <section><h1>Pydrake</h1>

    <p><drake></drake> is primarily a C++ library, with rigorous coding
    standards and a maturity level intended to support even professional
    applications in industry.  In order to provide a gentler introduction, and
    to facilitate rapid prototyping, I've written these notes exclusively in
    python, using Drake's python bindings (pydrake).  These bindings are less
    mature than the C++ backend; your feedback (and even contributions) are very
    welcome. It is still improving rapidly.</p>

    <p>In particular, while the C++ API documentation is excellent, the autogenerated python docs are still a work in progress.  I currently recommend using the <a href="https://drake.mit.edu/doxygen_cxx/">C++ documentation</a> to find what you need, then checking the <a href="https://drake.mit.edu/pydrake/">Python documentation</a> only if you need to understand how the class or method is spelled in pydrake.</p>

    <p>There are also a number of <a href="https://nbviewer.jupyter.org/github/RobotLocomotion/drake/tree/master/tutorials/">tutorials</a> in <drake></drake> that can help you get started.</p>

  </section>

  <section><h1>Online Jupyter notebooks</h1>

    <p>I will provide nearly all examples and exercises in the form of a <a
    href="http://jupyter.org/">Jupyter Notebook</a> so that we can leverage the
    fantastic and relatively recent availability of (free) cloud resources. In
    particular I have chosen to focus on using <a
    href="http://colab.research.google.com">Google's Colaboratory</a> (Colab) as
    our primary platform. Most of the chapters have a corresponding notebook
    that you can run on the cloud without installing anything on your
    machine!</p>

    <p>Colab is a fantastic resource, with generous computational resources and
    a very convenient interface that allows you to save/load/share your work on
    Google Drive.  Although we cannot provision the machines ahead of time, we
    can provision them quickly with a slightly ugly install script at the top of
    every notebook.  The first time you open each notebook it takes about two
    minutes to provision the machine.  At the time of this writing, it seems
    that the machine will stay provisioned for you <a
    href="https://stackoverflow.com/questions/54057011/google-colab-session-timeout">for
    90 minutes if you close the browser, or 12 hours if you keep it open.</a>
    Provisioning is per user and appears relatively unlimited.</p>

  </section>

  <section><h1>Running on your own machine</h1>

    <p>As you get more advanced, you will want to run (and extend) these examples on your own machine.  The <drake></drake> website has a number of <a href="https://drake.mit.edu/installation.html">installation options</a>, including precompiled binaries and Docker instances.  Here I provide an example workflow of setting up drake from the precompiled binaries and running the textbook examples.</p>

    <p>First, pick your platform (click on your OS):</p>

    <p style="text-align:center">
    <span class="bionic">
      <b>Ubuntu Linux (Bionic)</b>  |
      <span onclick="setPlatform('mac');" style="text-decoration:underline;cursor:pointer">Mac Homebrew</span>
    </span>
    <span class="mac">
      <span onclick="setPlatform('bionic');"
            style="text-decoration:underline;cursor:pointer">Ubuntu Linux
        (Bionic)</span>  |
      <b>Mac Homebrew</b> </span></p>

    <subsection><h1>Install Drake</h1>

      <p>The links below indicate the specific distributions that the
      examples in this text have been tested against.</p>

      <h4 >Download the binaries</h4>

      <div class="bionic"><pre class="highlight"><code>curl -o drake.tar.gz <div id="drake-bionic-binaries" style="display:inline">https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-bionic.tar.gz</div></code></pre></div>

      <div class="mac"><pre class="highlight"><code>curl -o drake.tar.gz <div id="drake-mac-binaries" style="display:inline">https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-mac.tar.gz</div></code></pre></div>

      <h4>Unpack and set your PYTHONPATH and Test</h4>

      <div class="bionic"><pre class="highlight"><code>sudo tar -xvzf drake.tar.gz -C /opt
sudo /opt/drake/share/drake/setup/install_prereqs
export PYTHONPATH=/opt/drake/lib/python3.6/site-packages:${PYTHONPATH}

python3 -c 'import pydrake; print(pydrake.__file__)</code></pre></div>

      <div class="mac"><pre class="highlight"><code>sudo tar -xvzf drake.tar.gz -C /opt
/opt/drake/share/drake/setup/install_prereqs.sh
export PYTHONPATH=/opt/drake/lib/python3.8/site-packages:${PYTHONPATH}
export PATH=/usr/local/opt/python@3.8/bin:${PATH}

python3 -c 'import pydrake; print(pydrake.__file__)</code></pre></div>

    </section>

    <subsection><h1>Download the textbook supplement</h1>

      <div><pre class="highlight"><code>git clone https://github.com/RussTedrake/manipulation.git</code></pre></div>

      <p>and install the prerequisites using the platform-specific installation script provided:</p>

      <div class="bionic"><pre class="highlight"><code>cd manipulation
sudo scripts/setup/ubuntu/18.04/install_prereqs.sh
pip3 install --requirement requirements.txt
export PYTHONPATH=`pwd`:${PYTHONPATH}</code></pre></div>

      <div class="mac"><pre class="highlight"><code>cd manipulation
scripts/setup/mac/install_prereqs.sh
pip3 install --requirement requirements.txt /opt/drake/share/drake/setup/requirements.txt
export PYTHONPATH=`pwd`:${PYTHONPATH}</code></pre></div>

      <p>Note that, as always, I would strongly recommend running
      <code>pip</code>
      commands in a <a
      href="https://python-guide-cn.readthedocs.io/en/latest/dev/virtualenvs.html">virtualenv</a>.</p>

    </subsection>

    <subsection><h1>Run Jupyter Notebook</h1>

      <p>You'll likely want to start from the manipulation root directory.  Then launch your notebook with:</p>

      <div><pre class="highlight"><code>jupyter notebook</code></pre></div>

      <p>The examples for each chapter that has them will be in a .ipynb file
      right alongside the chapter's html file, and the notebook exercises are
      all located in the<code>exercises</code> subdirectory.  
    </subsection>

  </section>

  <section><h1>Getting help</h1>

    <p>If you have trouble with <drake></drake>, please follow the advice <a href="https://drake.mit.edu/getting_help.html">here</a>.  If you have trouble with the manipulation repo, you can check for known issues (and potentially file a new one) <a href="https://github.com/RussTedrake/manipulation/issues">here</a>.</p>

  </section>

    <div style="height:30px"></div>

</chapter>
<!-- EVERYTHING BELOW THIS LINE IS OVERWRITTEN BY THE INSTALL SCRIPT -->

<table style="width:100%;"><tr style="width:100%">
  <td style="width:33%;text-align:left;"><a class="previous_chapter" href=rl.html>Previous Chapter</a></td>
  <td style="width:33%;text-align:center;"><a href=index.html>Table of contents</a></td>
  <td style="width:33%;text-align:right;"><a class="next_chapter" href=station.html>Next Chapter</a></td>
</tr></table>

<div id="footer">
  <hr>
  <table style="width:100%;">
    <tr><td><a href="https://accessibility.mit.edu/">Accessibility</a></td><td style="text-align:right">&copy; Russ
      Tedrake, 2020</td></tr>
  </table>
</div>


</body>
</html>
